package com.three.controller;

import com.baor.baseUtil.R;
import com.three.domain.Logs;
import com.three.service.LogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class LogsController {
    @Autowired
    private LogsService logsService;
    @RequestMapping(value = "/logsListByStudent")
    public R logsList(@RequestBody Map<String, Object> map){
        Integer id = (Integer) map.get("user_id");
        Integer pageIndex = (Integer) map.get("pageIndex");
        Integer pageSize = (Integer) map.get("pageSize");
        return logsService.logsList(id,pageIndex,pageSize);
    }
    @RequestMapping(value = "/addLogsByStudent")
    public R addLogs(@RequestBody Logs logs){
        return logsService.addLogs(logs);
    }




    @RequestMapping(value = "/logslist")
    public R logslist(@RequestBody Map<String, Object> map) {
        int pageIndex = (int) map.get("pageIndex");
        int pageSize = (int) map.get("pageSize");
        return logsService.LogsListByStudent(pageIndex, pageSize);
    }
    @RequestMapping ("/updatelog")
    public ResponseEntity<?> updateLog(@RequestParam Integer log_id, @RequestBody Logs log) {
        log.setLog_id(log_id);  // 设置日志 ID
        logsService.updateLog(log);
        return ResponseEntity.ok("日志更新成功");
    }
}
